package com.itheima.sc;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@Slf4j
@SpringBootApplication
public class DbApp {
    public static void main(String[] args) {
        SpringApplication.run(DbApp.class, args);
        log.info("DbApp程序执行成功!");
    }

    //构建分页拦截器

    @Bean
    public MybatisPlusInterceptor interceptor() {
        //创建mybatisplus中的内部拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //构建分页拦截器
        PaginationInnerInterceptor innerInterceptor = new PaginationInnerInterceptor(DbType.H2);
        //将分页拦截器加载到内部的拦截器中
        interceptor.addInnerInterceptor(innerInterceptor);

        return interceptor;
    }

}
